fix(spanner): escape embedded backticks in dbapi escape_name#17810
Open
sakthivelmanii wants to merge 1 commit into
Open
fix(spanner): escape embedded backticks in dbapi escape_name#17810sakthivelmanii wants to merge 1 commit into
sakthivelmanii wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the escape_name function in parse_utils.py to escape backticks by doubling them, and adds corresponding unit tests. The review feedback points out a critical security vulnerability (SQL injection) where identifiers containing other special characters (such as comments or semicolons) but no spaces, hyphens, or backticks could bypass escaping. A code suggestion is provided to resolve this by strictly validating identifiers and escaping any that are not valid regular ASCII identifiers.
sakthivelmanii
force-pushed
the
fix-spanner-dbapi-escape-name
branch
2 times, most recently
from
July 22, 2026 04:49
044851b to
15dcb8a
Compare
In google-cloud-spanner DB-API, escape_name() did not check for or double embedded backtick characters (`) when wrapping identifiers. This allowed identifiers containing backticks to break out of backtick-quoted identifier scopes (CWE-89 identifier injection).
This commit updates escape_name() to:
- Detect embedded backtick characters in identifier names.
- Escape internal backticks by doubling them (replace("`", "``")) when enclosing identifiers in backticks.
- Add unit test cases for embedded backticks in test_escape_name.
sakthivelmanii
force-pushed
the
fix-spanner-dbapi-escape-name
branch
from
July 23, 2026 08:13
15dcb8a to
579da90
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In google-cloud-spanner DB-API, escape_name() did not check for or double embedded backtick characters (`) when wrapping identifiers. This allowed identifiers containing backticks to break out of backtick-quoted identifier scopes (CWE-89 identifier injection).
This commit updates escape_name() to:
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕